package com.cgy.repository;

import java.util.List;
import java.util.Map;

import javax.transaction.Transactional;

import org.springframework.data.domain.Page;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.cgy.entity.Computer;

public interface ComputerRepository extends JpaRepository<Computer, Integer>,JpaSpecificationExecutor<Computer> {
	@Query(value = "delete from Computer WHERE cid=?1")  
    @Modifying 
    @Transactional 
	Integer deleteComputer(Integer cid);
	//修改状态为上机
	@Query(value = "update  Computer set c_status='1' WHERE cid=?1",nativeQuery = true)  
    @Modifying  
    @Transactional 
	Integer upcomputerstaticsj(Integer cid);
	//修改状态为下机
	@Query(value = "update  Computer set c_status='0' WHERE cid=?1",nativeQuery = true)  
    @Modifying  
    @Transactional 
	Integer upcomputerstaticxj(Integer cid);
	//根据资源室id查询资源
		@Query(value = "SELECT * FROM computer where zid=?1",nativeQuery = true)  
		List<Computer> findAllByzid(Map<String, Object> map);
		//查询总条数
		@Query(value = "SELECT count(*) FROM computer where zid=?1",nativeQuery = true) 
		Integer findAllByzidCount(Map<String, Object> map);
		
	
}
